package com.zzptc.easyshop.servlet;

import com.zzptc.easyshop.dao.UserDao;
import com.zzptc.easyshop.vo.Users;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

@WebServlet(name = "Login Servlet")
public class LoginServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doGet(request, response);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    response.setCharacterEncoding("utf-8");
    PrintWriter pw = response.getWriter();
    String unaem = request.getParameter("userName");
    String pass = request.getParameter("passWord");
    Users users = new Users();
    pw.print(unaem + "，hello!");        //打印在网页上
    users.setEu_user_name(unaem);
    users.setEu_password(pass);
    UserDao userDao = new UserDao();
    boolean i = false;
    i = userDao.login(users);
    if (i){
        pw.print(unaem + "______成功11");
    } else{
        pw.print(unaem + "______失败00");
    }
    }
}